import { Entity, PrimaryGeneratedColumn, Column, OneToMany, CreateDateColumn, ManyToOne } from 'typeorm';
import { User } from './User';
import { Comment } from './Comment'
@Entity()
export class Shop {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  title: string;

  @Column({ type: 'text' })
  cover: string;

  @Column({ type: 'text' })
  content: string;

  @Column()
  price: number;

  @CreateDateColumn()
  createdDate: Date;

  @ManyToOne(() => User, (user) => user.posts)
  user: User;

  @Column({ nullable: true })
  userId: string;


  @OneToMany(() => Comment, (comment) => comment.post)
  comments: Comment[];

  @Column({ default: 1 })  //上架 1  下架0 
  status: number;

}
